package com.example.myroomdemo.beans.roomSql

import androidx.room.*
import com.example.myroomdemo.beans.Users


@Dao
interface UserDao {

    @Query("SELECT * FROM Users")
    fun getAllData(): MutableList<Users?>?
/*
    @get:Query("SELECT * FROM Users")
    val all: MutableList<Users?>?
*/

    @Query("SELECT * FROM Users WHERE roomID IN (:userIds)")
    fun loadAllByIds(userIds: IntArray?): MutableList<Users?>?

    @Query("SELECT * FROM Users WHERE strName IN (:names)")
    fun loadAllByNames(names: Array<String?>?): MutableList<Users?>?

    /* @Query("SELECT * FROM Users WHERE first_name LIKE :first AND "
            + "last_name LIKE :last LIMIT 1")
    Users findByName(String first, String last);*/
    //改
    @Update
    open fun update(users: MutableList<Users>?): Unit

    @Insert
    fun insertAll(users: MutableList<Users>?)

    @Insert
    fun insertOne(users: Users?)

    @Delete
    fun delete(user: Users?)

    @Query("DELETE FROM Users")
    fun deleteALl()
}